package com.epam;

import java.lang.reflect.Field;

public class Main {


	public static void main(String[] args) throws NoSuchFieldException,
			SecurityException, IllegalArgumentException, IllegalAccessException {
		// Class[] clases=new Class[4];
		// clases[0]=First.class;
		// clases[1]=Second.class;
		// clases[2]=Third.class;
		// clases[3]=Fourth.class;
		// // ClassLoader classLoader = Main.class.getClassLoader();
		//
		//
		// for(int index=0;index<clases.length;index++){
		// Annotation[] annotat=clases[index].getAnnotations();
		// for(int i=0;i<annotat.length;i++){
		// if (annotat[i] instanceof Anot)
		// System.out.println(clases[index].getName());
		// }
		// }
		
	 First f1=new First();
	 @SuppressWarnings("rawtypes")
	Class clazz = First.class;
	 

	 Field[] field=clazz.getDeclaredFields();
	 for(int i=0;i<field.length;i++){
		 if (field[i].getType()==String.class){
			 System.out.println("BEFORE "+field[i].get(f1));
			 setField(field[i]);
			 System.out.println("AFTER "+field[i].getName());
		 }
			 
			 
	 }

	
	

		
		
	}

	public static void setField(Object inst1) throws NoSuchFieldException,
	SecurityException, IllegalArgumentException, IllegalAccessException {
		Field field = inst1.getClass().getDeclaredField("name");
		field.setAccessible(true);
		field.set(inst1, "NEW NEW");
	}
}
